package com.qf.day13.map;

import java.util.*;

/**
 * 键值对结构
 */
public class MapDemo {

    public static void main(String[] args) {

        // 如何存放键值对数据
        HashMap<String, String> dict = new HashMap<>();

        dict.put("hello","你好"); // 存放键值对
        dict.put("world","世界");
        dict.put("hash","哈希");
        dict.put("hello","你好！");
        System.out.println(dict.get("hello"));
        System.out.println(dict.size());

//        dict.remove("hello");
//        System.out.println(dict.get("hello"));

//        System.out.println(dict.containsValue("你好"));
//        System.out.println(dict.containsKey("hello1"));

//        Set<Map.Entry<String, String>> entries = dict.entrySet();
//        System.out.println(entries);
//
//        for (Map.Entry<String, String> entry : entries) {
//            System.out.println(entry.getKey()+":"+entry.getValue());
//        }


//        Collection<String> values = dict.values();
//        System.out.println(values);

        // 获取 hashmap中所有的key
//        Set<String> keySet = dict.keySet();
//        System.out.println(keySet);

        // 如何根据key获取value
//        String s = dict.get("hello");
//        System.out.println(s);
//        System.out.println(dict.get("world"));
//        System.out.println(dict.get("hash11")); // 如果key不存在则返回null


//        Properties properties = System.getProperties();
////        properties.forEach((k,v)-> System.out.println(k+"="+v));
//
//        System.setProperty("appName","doudizhu");
//        String property = System.getProperty("appName");
//        System.out.println(property);

    }
}
